package com.alquiler.controllers;

import java.util.Timer;
import java.util.TimerTask;

import com.alquiler.managers.SimpleEntityManager;
import com.alquiler.utils.ConstantesVistas;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;



public class ScreensFramework extends Application{
		
	private Stage stage;
	
	public MainController mainContainer = new MainController();
	
	
    
    
    @Override
    public void start(Stage primaryStage) {
        
    	stage = primaryStage;
    	
    	stage.setTitle("Sistema Huella Digital");
    	
    	SimpleEntityManager.getInstance();
    	
        mainContainer.setStage(stage);        
        
      mainContainer.setVista(ConstantesVistas.screenLogin);   
//      mainContainer.setVista(ConstantesVistas.screenLayout);  	  
//      mainContainer.setVista(ConstantesVistas.screenVerificacionHuella);
     
        Group root = new Group();
        root.getChildren().addAll(mainContainer);
 
        Scene scene = new Scene(root);
        
        scene.getStylesheets().add(getClass().getResource("/com/alquiler/styles/application.css").toExternalForm());        

        stage.setScene(scene); 
        stage.setResizable(false); 
        
        stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
            public void handle(WindowEvent e) {  
            	
            	SimpleEntityManager.getInstance().close();
            	//((Stage) e.getTarget()).close();
            	System.exit(0);
            	
//            	try {
//            		e.consume();
//            		mainContainer.getModalConfirmacion(ConstantesVistas.screenModalConfirmacion);
//					
//				} catch (Exception er) {
//					er.printStackTrace();
//					SimpleEntityManager.getInstance().close();
//					((Stage) e.getTarget()).close();
//				}            	
            }
        });
        
        stage.show();
    }

 
    public static void main(String[] args) {
        launch(args);          
        
    } 
    
   

}
